<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
		"http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>doh.robot TooltipDialog A11y Test</title>

		<style>
			@import "../../../util/doh/robot/robot.css";
		</style>

		<!-- required: dojo.js -->
		<script type="text/javascript" src="../../../dojo/dojo.js"
			djConfig="isDebug: true"></script>

		<!-- functions to help test -->
		<script type="text/javascript" src="../helpers.js"></script>

		<script type="text/javascript">
			dojo.require("dijit.dijit"); // optimize: load dijit layer
			dojo.require("dijit.robotx");

			dojo.addOnLoad(function(){
				doh.robot.initRobot('../test_TooltipDialog.html');

				function testOK(deferred, delay){
					doh.robot.sequence(dojo.hitch(deferred, "callback", true), delay? delay : 1);
				}

				doh.register("TooltipDialog normal operation", [
					{
						name: "programmatically opened",
						timeout: 10000,
						runTest: function(){
							var d = new doh.Deferred();
							var button = dijit.byId("tooltipDlgButton");
							var inlineBox;
							doh.robot.sequence(function(){
								button.focus();
								button.openDropDown();
							}, 1000, 1000);
							doh.robot.sequence(d.getTestCallback(function(){
								doh.t(button._opened, "TooltipDialog should be showing after programmatically opened");
								button.closeDropDown(true);
							}), 1000);
							return d;
						}
					},
					{
						name: "closes on Esc",
						timeout: 10000,
						runTest: function(){
							var d = new doh.Deferred();
							var button = dijit.byId("tooltipDlgButton");
							var inlineBox;
							doh.robot.sequence(function(){
								button.focus();
								button.openDropDown();
							}, 1000, 1000);
							doh.robot.keyPress(dojo.keys.ESCAPE, 500, {});
							doh.robot.sequence(d.getTestCallback(function(){
								doh.f(button._opened, "TooltipDialog should not be showing after Esc");
							}), 1000);
							return d;
						}
					}
				]);

				doh.register("interacton with InlineEditBox autosave", [
					{
						name: "InlineEditBox edit mode then Esc",
						timeout: 10000,
						runTest: function(){
							var d = new doh.Deferred();
							var button = dijit.byId("tooltipDlgButton");
							var inlineBox, initialValue;
							doh.robot.sequence(function(){
								button.focus();
								button.openDropDown();
								inlineBox = dijit.byId("user");
								initialValue = inlineBox.attr("value");
								inlineBox.edit();
							}, 1000, 1000);
							doh.robot.keyPress(dojo.keys.ESCAPE, 1000, {});
							doh.robot.sequence(d.getTestCallback(function(){
								doh.t(button._opened, "TooltipDialog should be showing");
								doh.f(inlineBox.editing, "Esc should have exited edit mode");
								doh.is(initialValue, inlineBox.attr("value"), "initial value was inline");
								button.closeDropDown(true);
							}), 1000);
							return d;
						}
					},
					{
						name: "InlineEditBox edit mode, change value, then Esc",
						timeout: 10000,
						runTest: function(){
							var d = new doh.Deferred();
							var button = dijit.byId("tooltipDlgButton");
							var inlineBox, initialValue;
							doh.robot.sequence(function(){
								button.focus();
								button.openDropDown();
								inlineBox = dijit.byId("user");
								initialValue = inlineBox.attr("value");
								inlineBox.edit();
							}, 1000, 1000);
							doh.robot.typeKeys("esc", 1000, 600);
							doh.robot.keyPress(dojo.keys.ESCAPE, 100, {});
							doh.robot.sequence(d.getTestCallback(function(){
								doh.t(button._opened, "TooltipDialog should be showing");
								doh.f(inlineBox.editing, "Esc should have exited edit mode");
								doh.is(initialValue, inlineBox.attr("value"), "value should revert back to inline");
								button.closeDropDown(true);
							}), 1000);
							return d;
						}
					},
					{
						name: "InlineEditBox edit mode, change value, then Tab",
						timeout: 10000,
						runTest: function(){
							var d = new doh.Deferred();
							var button = dijit.byId("tooltipDlgButton");
							var inlineBox;
							doh.robot.sequence(function(){
								button.focus();
								button.openDropDown();
								inlineBox = dijit.byId("user");
								inlineBox.edit();
							}, 1000, 1000);
							doh.robot.typeKeys("tab", 1000, 600);
							doh.robot.keyPress(dojo.keys.TAB, 100, {});
							doh.robot.sequence(d.getTestCallback(function(){
								doh.t(button._opened, "TooltipDialog should be showing");
								doh.f(inlineBox.editing, "Tab should have exited edit mode");
								doh.is('tab', inlineBox.attr("value"), "value should have changed to tab");
								button.closeDropDown(true);
							}), 1000);
							return d;
						}
					},
					{
						name: "InlineEditBox edit mode, change value, then Enter",
						timeout: 10000,
						runTest: function(){
							var d = new doh.Deferred();
							var button = dijit.byId("tooltipDlgButton");
							var inlineBox;
							doh.robot.sequence(function(){
								button.focus();
								button.openDropDown();
								inlineBox = dijit.byId("user");
								inlineBox.edit();
							}, 1000, 1000);
							doh.robot.typeKeys("enter", 1000, 1000);
							doh.robot.keyPress(dojo.keys.ENTER, 100, {});
							doh.robot.sequence(d.getTestCallback(function(){
								doh.t(button._opened, "TooltipDialog should be showing");
								doh.f(inlineBox.editing, "Enter should have exited edit mode");
								doh.is('enter', inlineBox.attr("value"), "value should have changed to enter");
								button.closeDropDown(true);
							}), 2000);
							return d;
						}
					},
					{
						name: "InlineEditBox focused after Esc",
						timeout: 10000,
						runTest: function(){
							var d = new doh.Deferred();
							var button = dijit.byId("tooltipDlgButton");
							var inlineBox;
							doh.robot.sequence(function(){
								button.focus();
								button.openDropDown();
								inlineBox = dijit.byId("user");
								inlineBox.edit();
							}, 1000, 1000);
							doh.robot.keyPress(dojo.keys.ESCAPE, 1000, {});
							doh.robot.keyPress(dojo.keys.ENTER, 1000, {});
							doh.robot.sequence(d.getTestCallback(function(){
								doh.t(button._opened, "TooltipDialog should be showing");
								doh.t(inlineBox.editing, "Enter should have reentered edit mode");
								inlineBox.cancel(true);
								button.closeDropDown(true);
							}), 2000);
							return d;
						}
					},
					{
						name: "InlineEditBox focused after Enter",
						timeout: 10000,
						runTest: function(){
							var d = new doh.Deferred();
							var button = dijit.byId("tooltipDlgButton");
							var inlineBox;
							doh.robot.sequence(function(){
								button.focus();
								button.openDropDown();
								inlineBox = dijit.byId("user");
								inlineBox.edit();
							}, 1000, 1000);
							doh.robot.typeKeys("enter", 1000, 1000);
							doh.robot.keyPress(dojo.keys.ENTER, 200, {});
							doh.robot.keyPress(dojo.keys.ENTER, 1000, {});
							doh.robot.sequence(d.getTestCallback(function(){
								doh.t(button._opened, "TooltipDialog should be showing");
								doh.t(inlineBox.editing, "2nd Enter should have reentered edit mode");
								inlineBox.cancel(true);
								button.closeDropDown(true);
							}), 2000);
							return d;
						}
					},
					{
						name: "InlineEditBox focused after Tab/Shift+Tab",
						timeout: 10000,
						runTest: function(){
							var d = new doh.Deferred();
							var button = dijit.byId("tooltipDlgButton");
							var inlineBox;
							doh.robot.sequence(function(){
								button.focus();
								button.openDropDown();
								inlineBox = dijit.byId("user");
								inlineBox.edit();
							}, 1000, 1000);
							doh.robot.typeKeys("tab", 1000, 600);
							doh.robot.keyPress(dojo.keys.TAB, 100, {});
							doh.robot.keyPress(dojo.keys.TAB, 1000, {shift:true});
							doh.robot.keyPress(dojo.keys.ENTER, 500, {});
							doh.robot.sequence(d.getTestCallback(function(){
								doh.t(button._opened, "TooltipDialog should be showing");
								doh.t(inlineBox.editing, "Enter after shift+Tab should have reentered edit mode");
								inlineBox.cancel(true);
								button.closeDropDown(true);
							}), 2000);
							return d;
						}
					}
				]);

				doh.run();
			});
		</script>
	</head>
</html>
